package com.coderman.basketball.statistics.context;

import lombok.Data;

import java.util.Map;

/**
 * Description:
 * date: 2021/5/27
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Data
public class GameDataBO {
    private Long gameId;
    /**
     * 主队分数:客队分数
     */
    private String score;

    /**
     * 主队名称
     */
    private String mainTeamName;

    /**
     * 客队名称
     */
    private String clientTeamName;

    /**
     * 主队统计数据
     */
    private Map<String, Integer> mainTeamDataMap;

    /**
     * 客队统计数据
     */
    private Map<String, Integer> clientTeamDataMap;


    /**
     * 增加客队分数
     *
     * @param score
     */
    public void incrClientTeamScore(int score) {
        String[] scoreArr = this.score.split(":");
        int clientScore = Integer.parseInt(scoreArr[1]) + score;
        this.score = scoreArr[0] + clientScore;
    }

    /**
     * 增加主队分数
     * @param score
     */
    public void incrMainTeamScore(int score) {
        String[] scoreArr = this.score.split(":");
        int mainScore = Integer.parseInt(scoreArr[0]) + score;
        this.score = mainScore + scoreArr[1];
    }


    /**
     * 更新主队统计数据
     * @param key
     * @param value
     */
    public void incrMainTeamKeyValue(String key,int value) {
        Integer oldValue = this.mainTeamDataMap.get(key);
        if(oldValue == null){
            oldValue = value;
        }else {
            oldValue = oldValue + value;
        }
        this.mainTeamDataMap.put(key,oldValue);
    }


    /**
     * 更新主队统计数据
     * @param key
     * @param value
     */
    public void incrClientTeamKeyValue(String key,int value) {
        Integer oldValue = this.clientTeamDataMap.get(key);
        if(oldValue == null){
            oldValue = value;
        }else {
            oldValue = oldValue + value;
        }
        this.clientTeamDataMap.put(key,oldValue);
    }
}
